package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.List;

import com.xcity.db.entity.Player;
import com.xcity.game.battle.pve.PVEManager;
import com.xcity.game.battle.pve.PVEStage;
import com.xcity.game.battle.pve.template.StagePageTemplate;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class PVEStageListV2Response extends Response{

	private int page;
	private byte type;//0普通页 1精英页
	private int maxPage;
	private int heroReachPage;//精英关到达的最大页
	private int normalReachPage;//普通关通关最大数
	private int getStar;
	private String pageName;
	
	private byte starBoxState0;//星数宝箱的领取状态 -1:没有宝箱 0:未领取1:领取
	private byte starBoxState1;//星数宝箱的领取状态 -1:没有宝箱 0:未领取1:领取
	private byte starBoxState2;//星数宝箱的领取状态 -1:没有宝箱 0:未领取1:领取
	
	private byte needStar0;//第1个星数宝箱需要的星数  -1为没宝箱
	private byte needStar1;//第1个星数宝箱需要的星数  -1为没宝箱
	private byte needStar2;//第1个星数宝箱需要的星数  -1为没宝箱
	
	private String map;
	private List<SimpleStageInfoV2> stages;
	public static class SimpleStageInfoV2{
		public int id;
		public byte type;//0普通 1BOSS 2英雄
		public String name;
		public String icon;
		public int star;//0:未通过 1~3:1~3星
		public byte state;//状态(0:未解锁,1:已解锁)
		public int levelLimit;
		public byte boxState;//关卡宝箱状态 0没有宝箱 1有宝箱不可领取 2可领未领取 3已领取
		public int[] boxPos;//关卡宝箱位置
		public int[] stagePos;//关卡位置
		public String bossImg;
		public SimpleStageInfoV2(Player player, PVEStage stage){
			this.id = stage.getId();
			this.type = stage.getTemplate().getType();
			this.name = stage.getTemplate().getName();
			this.icon = stage.getTemplate().getIcon();
			this.star = stage.getStar();
			this.state = player.getPveStages().getLockStateByStage(stage);
			this.levelLimit = stage.getTemplate().getLevelLimit();
			this.boxState = stage.getStageBoxState();
			this.boxPos = stage.getTemplate().getBoxPos();
			this.stagePos = stage.getTemplate().getStagePos();
			
			this.bossImg = null;//
			if(stage.getTemplate().getType() != PVEManager.STAGE_TYPE_NORMAL){
				this.bossImg = stage.getTemplate().getBoss().getIcon();
			}
		}
	}
	
	public PVEStageListV2Response(int serial, int page, byte type, int maxPage, int heroReachPage, int normalReachPage, StagePageTemplate pageTemp, Player player, List<PVEStage> stageList, int getStar, byte[] gotStarBox) {
		super(serial);
		this.page = page;
		this.type = type;
		this.maxPage = maxPage;
		this.heroReachPage = heroReachPage;
		this.normalReachPage = normalReachPage;
		
		this.getStar = getStar;
		
		this.starBoxState0 = gotStarBox[0];
		this.starBoxState1 = gotStarBox[1];
		this.starBoxState2 = gotStarBox[2];
		
		this.map = pageTemp.getMapStr()[type];
		
		this.needStar0 = (byte) pageTemp.getNeedStar()[0 + type * StagePageTemplate.MAX_BOX_COUNT];
		this.needStar1 = (byte) pageTemp.getNeedStar()[1 + type * StagePageTemplate.MAX_BOX_COUNT];
		this.needStar2 = (byte) pageTemp.getNeedStar()[2 + type * StagePageTemplate.MAX_BOX_COUNT];
		
		this.stages = new ArrayList<SimpleStageInfoV2>(stageList.size());
		for(int i = 0;i < stageList.size(); i++){
			PVEStage stage = stageList.get(i);
			SimpleStageInfoV2 info = new SimpleStageInfoV2(player, stage);
			this.stages.add(info);
		}
		this.pageName = pageTemp.getPageName();
	}
	public int getPage() {
		return page;
	}
	public void setPage(int page) {
		this.page = page;
	}
	public int getMaxPage() {
		return maxPage;
	}
	public void setMaxPage(int maxPage) {
		this.maxPage = maxPage;
	}
	public int getHeroReachPage() {
		return heroReachPage;
	}
	public void setHeroReachPage(int heroReachPage) {
		this.heroReachPage = heroReachPage;
	}
	public int getGetStar() {
		return getStar;
	}
	public void setGetStar(int getStar) {
		this.getStar = getStar;
	}
	public byte getStarBoxState0() {
		return starBoxState0;
	}
	public void setStarBoxState0(byte starBoxState0) {
		this.starBoxState0 = starBoxState0;
	}
	public byte getStarBoxState1() {
		return starBoxState1;
	}
	public void setStarBoxState1(byte starBoxState1) {
		this.starBoxState1 = starBoxState1;
	}
	public byte getStarBoxState2() {
		return starBoxState2;
	}
	public void setStarBoxState2(byte starBoxState2) {
		this.starBoxState2 = starBoxState2;
	}
	public byte getNeedStar0() {
		return needStar0;
	}
	public void setNeedStar0(byte needStar0) {
		this.needStar0 = needStar0;
	}
	public byte getNeedStar1() {
		return needStar1;
	}
	public void setNeedStar1(byte needStar1) {
		this.needStar1 = needStar1;
	}
	public byte getNeedStar2() {
		return needStar2;
	}
	public void setNeedStar2(byte needStar2) {
		this.needStar2 = needStar2;
	}
	public String getMap() {
		return map;
	}
	public void setMap(String map) {
		this.map = map;
	}
	public List<SimpleStageInfoV2> getStages() {
		return stages;
	}
	public void setStages(List<SimpleStageInfoV2> stages) {
		this.stages = stages;
	}
	public byte getType() {
		return type;
	}
	public void setType(byte type) {
		this.type = type;
	}
	public String getPageName() {
		return pageName;
	}
	public void setPageName(String pageName) {
		this.pageName = pageName;
	}
	public int getNormalReachPage() {
		return normalReachPage;
	}
	public void setNormalReachPage(int normalReachPage) {
		this.normalReachPage = normalReachPage;
	}
}
